/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-05-15
 * Time: 19:22
 */
public class test_1 {
    public static int jewelleryValue(int[][] frame) {
        // 1. 创建 dp 表
        // 2. 初始化
        // 3. 填表
        // 4. 返回结果
        int m=frame.length;
        int n=frame[0].length;
        int[][] dp =new int[m+1][n+1];
        for (int i = 1; i <=m; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j]=frame[i-1][j-1]+Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }
        return dp[m][n];
    }
    public static void main(String[] args) {
        int[][] frame={{1,3,1},{1,5,1},{4,2,1}};
        System.out.println(jewelleryValue(frame));
    }
}
